<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>班级信息</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/login.css">
	  <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form">
				<div class="layui-form-item">
				
					<label for="conId" class="layui-form-label"> 
						id
					</label>
					<div class="layui-input-inline">
						<input type="text" id="conId" name="conId" autocomplete="off" readonly class="layui-input layui-disabled">
					</div>
					
					<label for="conName" class="layui-form-label"> 
						用户名
					</label>
					<div class="layui-input-inline">
						<input type="text" id="conName" name="conName" autocomplete="off" readonly class="layui-input layui-disabled">
					</div>
				</div>
				
				
				<div class="layui-form-item">
					<label for="conPwd" class="layui-form-label"> 
						修改密码
					</label>
					<div class="layui-input-inline">
						<input type="text" id="conPwd" name="conPwd" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				
				
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="updatePwd" lay-submit="">提交</button>
				</div>
				
			</form>
		</div>
	</div>
</body>
<script>
layui.use([ 'form', 'layer' ], function() {
	$ = layui.jquery;
	var form = layui.form, 
	layer = layui.layer;
	var conservator = "";
	  
	  /* 获取登录用户session*/
	    $.ajax({                    
        url : "/../conservator/getSession",
        async:false, 
        type : "POST",
        success : function(data) {
        	conservator = data;
        },                
    });
	    $(document).ready(function(){
	    	$("#conId").attr('value',conservator.conId);
	    }); 
	    $(document).ready(function(){
	    	$("#conName").attr('value',conservator.conName);
	    });
	//监听提交 这里的 submit是必须的关键之  然后括号里面的add 就是表单中的提交按钮中的lay-filter属性值   lay-filter="add"
	form.on('submit(updatePwd)', function(data) {
		console.log(data);
		 $.ajax({
            type : "POST",
            url : "/../conservator/updateConservator",
            data : data.field,
            success : function(result) {
            	if(result>0){
					layer.alert("修改成功", {
						icon : 6
					}, function() {
						// 获得frame索引
						var index = parent.layer.getFrameIndex(window.name);
						//关闭当前frame
						parent.layer.close(index);
						
						parent.location.reload();//刷新父页面更新修改后的表格数据
					});
            	}else{
            		//发异步，把数据提交给
					layer.alert("修改失败！", {
						icon : 5
					});
            	}
            }
        });
		return false;
	}); 
});
    </script>
    
</html>